import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Index from '../components/Product/index'
import Comm from '../components/Product/components/commodity.vue'
import Cate from '../components/Product/components/category.vue'
import Order from '../components/Product/components/order.vue'
import Users from '../components/Product/components/users.vue'


import Login from '../components/Login/login'

Vue.use(VueRouter)

const routes = [{
    path: '/',
    redirect: "/product/index"
  },
  {
    path: '/login',
    name: "login",
    component: Login
  },
  {
    path: '/product/index',
    name: 'Index',
    component: Index,
    meta: {
      title: "首页",
      requireAuth: true
    },
    children: [{
        path: "/",
        name: 'home',
        component: Home,
        meta: {
          title: "首页",
          requireAuth: true
        },
      },
      {
        path: "/product/index/comm",
        name: 'comm',
        component: Comm,
        meta: {
          title: "商品管理",
          requireAuth: true
        },
      },
      {
        path: "/product/index/cate",
        name: 'cate',
        component: Cate,
        meta: {
          title: "品类管理",
          requireAuth: true
        },
      },
      {
        path: "/product/index/order",
        name: 'order',
        component: Order,
        meta: {
          title: "订单管理",
          requireAuth: true
        },
      },
      {
        path: "/product/index/users",
        name: 'users',
        component: Users,
        meta: {
          title: "用户管理",
          requireAuth: true
        },
      },
      {
        path: '/tian',
        name: 'tian',
        component: () => import('../views/tian.vue'),
        meta: {
          title: "添加商品",
          requireAuth: true
        },
      },
      {
        path: '/ditu',
        name: 'ditu',
        component: () => import('../views/ditu.vue'),
        meta: {
          title: "地图",
          requireAuth: true
        },
      },

    ]
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import( /* webpackChunkName: "about" */ '../views/About.vue')
  },

  {

    path: '/my',
    name: 'My',
    component: () => import( /* webpackChunkName: "about" */ '../views/My.vue')
  },
  {
    path: '/news',
    name: 'News',
    component: () => import( /* webpackChunkName: "about" */ '../views/News.vue')

  },
]

const router = new VueRouter({
  routes
})

export default router